package com.cff.shorturl.context;

import java.text.ParseException;
import java.util.Date;
import java.util.Properties;

import com.cff.shorturl.util.Base62Util;
import com.cff.shorturl.util.DateUtil;
import com.cff.shorturl.util.Utils;

public class Context {
	public static String SYS_START_TIME = "startMon";
	static Properties configProperties = null;
	static {
		configProperties = Utils.loadPropertiesFile("config.properties");
	}

	public static String getString(String key) {
		return configProperties.getProperty(key);
	}

	public static String getTimeDiffBase62() throws ParseException {
		String mon = Context.getString(SYS_START_TIME);
		int diff = DateUtil.differentMonth(DateUtil.parse(mon, DateUtil.SimpleMonthPattern), new Date());
		String surl = Base62Util.encode(diff, 2);
		return surl;
	}
}
